# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Simon Hanna <simon dot hanna AT serve-me DOT info>

pkgname=python-zope-component
pkgver=6.0
pkgrel=1
pkgdesc="Represents the core of the Zope Component Architecture"
arch=('any')
url="https://github.com/zopefoundation/zope.component"
license=('ZPL')
depends=(
  'python'
  'python-setuptools'
  'python-zope-event'
  'python-zope-hookable'
  'python-zope-interface'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-wheel'
)
checkdepends=(
  'python-persistent'
  'python-pytest'
  'python-zope-configuration'
  'python-zope-i18nmessageid'
  'python-zope-location'
  'python-zope-proxy'
  'python-zope-security'
  'python-zope-testrunner'
)
optdepends=(
  'python-persistent: for persistent registry'
  'python-zope-configuration: for zcml'
  'python-zope-i18nmessageid: for zcml'
  'python-zope-location: for security'
  'python-zope-proxy: for security'
  'python-zope-security: for security'
)
source=("$url/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('0f27ce6a901d780d0ff35718698b140d8f4763fed14f95a483ce984e55e25b54a35c5dfde9205dbf8436e96b6f3ecb4b560a46cf5bc8ccd3875b859796b0c1e9')
b2sums=('b5c0e1f6326c74e28b9534b50d7fba65215ad6786679e4dc2a340a22b7ab45c45e8f692141c1d48d100f407fcdb4dd4a3e8a120890dbed5f77a5fbd2d2243c96')

build() {
  cd zope.component-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd zope.component-$pkgver

  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  local pytest_options=(
    -vv
    # (blanket) ignore tests that fail due to different exposed interface
    --ignore "$(pwd)/test_dir/$site_packages/zope/component/tests/test_interface.py"
  )

  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="$(pwd)/test_dir/$site_packages:$PYTHONPATH"
  pytest "${pytest_options[@]}" "$(pwd)/test_dir/$site_packages"
}

package() {
  cd zope.component-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
}

# vim:set ts=2 sw=2 et:
